// Copyright (c) 2009 Alistair Jones
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.codegen;

import static org.hypirinha.html.codegen.CodegenUtil.capitalise;

import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Collection;

public class Text {

    private SortedSet<String> containingElementTypes = new TreeSet<String>();

    public GeneratedClass createTextClass() {
        GeneratedClass generatedClass = new GeneratedClass("org.hypirinha.html", "Text");
        generatedClass.addImport("org.hypirinha.html.elements.contents.*");
        generatedClass.addImport("org.hypirinha.html.output.Visitor");

        for (String elementType : containingElementTypes) {
            generatedClass.addInterface(CodegenUtil.capitalise(elementType) + "Content");
        }
        generatedClass.getMembers().add(new Field("content", "String"));
        generatedClass.getMembers().add(new Constructor("Text", "String content", "this.content = content;"));
        generatedClass.getMembers().add(new ConcreteMethod("visit", "void", "Visitor visitor", "visitor.text(content);"));
        return generatedClass;
    }

    public void addContainingElementTypes(Collection<String> elementTypes) {
        containingElementTypes.addAll(elementTypes);
    }
}